import { Models } from '@/common/typings/modle'

export const SESSION_KEY = {
  user: 'user',
}

export function setSession(ctx: Models.Ctx, key: string, value: any) {
  if (ctx.session) {
    ctx.session[key] = value
  } else {
    // @ts-ignore
    ctx.session = {
      [key]: value,
    }
  }
}
export function getSession(ctx: Models.Ctx, key: string) {
  if (ctx.session) {
    return ctx.session[key]
  } else {
    return null
  }
}
